<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:a="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                template="layout/template.xhtml">
                       
<ui:define name="body">
    
    <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>

    <h:form id="kreditniZahtev" styleClass="edit">
    
        <rich:panel>
            <f:facet name="header">#{kreditniZahtevHome.managed ? 'Izmena postojeceg' : 'Podnosenje novog'} kreditnog zahteva</f:facet>

            <s:decorate id="korisnikDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Podnosilac zahteva</ui:define>
                <h:outputText id="korisnik" 
                          value="#{ulogovaniKorisnik.ime} #{ulogovaniKorisnik.prezime}, #{ulogovaniKorisnik.jmbg}" 
                           size="65">
                    <a:support event="onblur" reRender="korisnikDecoration" bypassUpdates="false" ajaxSingle="true"/>
                </h:outputText>
               
            </s:decorate>
<!-- <s:decorate id="brojZahtevaDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Broj zahteva</ui:define>
                <h:inputText id="brojZahteva" 
                          value="#{kreditniZahtevHome.instance.brojZahteva}"
                           size="29">
                    <a:support event="onblur" reRender="brojZahtevaDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>
 -->
            <s:decorate id="iznosDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Iznos kredita</ui:define>
                <h:inputText id="iznos" 
                          value="#{kreditniZahtevHome.instance.iznos}"
                           size="17" 
                           converter="javax.faces.BigDecimal">
                           
                    <a:support event="onblur" reRender="iznosDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

            <s:decorate id="valutaDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Valuta</ui:define>
				    <h:selectOneMenu value="#{kreditniZahtevHome.instance.valuta}"  >
				     <s:selectItems value="#{valutaList}" var="valuta" label="#{valuta.oznaka}"/>
				     	<s:convertEntity/>
				    </h:selectOneMenu>
            </s:decorate>    
<!--<s:decorate id="iznosrateDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Iznos rate</ui:define>
                <h:inputText id="iznosrate" 
                          value="#{kreditniZahtevHome.instance.iznosRate}"
                           size="17">
                    <a:support event="onblur" reRender="iznosrateDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>
 -->

            <s:decorate id="iznosUcescaDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Iznos ucesca</ui:define>
                <h:inputText id="iznosUcesca" 
                          value="#{kreditniZahtevHome.instance.iznosUcesca}"
                           size="15"
                           converter="javax.faces.BigDecimal">
                    <a:support event="onblur" reRender="iznosUcescaDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

            <s:decorate id="rokDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Rok kredita</ui:define>
                <h:inputText id="rok" 
                          value="#{kreditniZahtevHome.instance.rok}"
                           size="4"
                           converter="javax.faces.Integer">
                    <a:support event="onblur" reRender="rokDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>
            
            <s:decorate id="tipRocnostiDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Tip rocnosti</ui:define>
				    <h:selectOneMenu value="#{kreditniZahtevHome.instance.tipRocnosti}"  >
				     <s:selectItems value="#{tipRocnostiList}" var="tipRocnosti" label="#{tipRocnosti.naziv}" />
				     	<s:convertEntity/>
				    </h:selectOneMenu>
            </s:decorate>              
            
            <s:decorate id="namenaDecoration" template="layout/edit.xhtml" >
                <ui:define name="label">Namena kredita</ui:define>
			    <h:selectOneMenu value="#{kreditniZahtevHome.instance.namena}">
			     <s:selectItems value="#{namenaList}" var="namena" label="#{namena.naziv}"/>
			     	<s:convertEntity/>
			    </h:selectOneMenu>
            </s:decorate>             
 
        
            <div style="clear:both">
                <span class="required">*</span> 
                obavezna polja
            </div>
            
        </rich:panel>
    
                
        <div class="actionButtons">

            <h:commandButton id="save" 
                          value="Snimi" 
                         action="#{kreditniZahtevHome.persist}"
                       disabled="#{!kreditniZahtevHome.wired}"
                       rendered="#{!kreditniZahtevHome.managed}"/>  
                          			  
            <h:commandButton id="update" 
                          value="Izmeni" 
                         action="#{kreditniZahtevHome.update}"
                       rendered="#{kreditniZahtevHome.managed}"/>
                        			  
            <h:commandButton id="delete" 
                          value="Obrisi" 
                         action="#{kreditniZahtevHome.remove}"
                      immediate="true"
                       rendered="#{kreditniZahtevHome.managed}"/>
                    
            <s:button id="done" 
                   value="Nazad"
             propagation="end"
                    view="/KreditniZahtev.xhtml"
                rendered="#{kreditniZahtevHome.managed}"/>
                
            <s:button id="cancel" 
                   value="Odustani"
             propagation="end"
                    view="/#{empty kreditniZahtevFrom ? 'KreditniZahtevList' : kreditniZahtevFrom}.xhtml"
                rendered="#{!kreditniZahtevHome.managed}"/>

        </div>
    </h:form>

</ui:define>

</ui:composition>
